//
//  GHItemCell.swift
//  GHSwiftProject
//
//  Created by Guanghui Liao on 6/11/18.
//  Copyright © 2018 liaoworking. All rights reserved.
//

import UIKit
import Kingfisher

///按钮位置的枚举
enum btnClickPosition {
    case left
    case right
}

class GHItemCell: UITableViewCell {

    /// 上面的图片
    @IBOutlet private weak var topImageView: UIImageView!
    /// 左边的按钮
    @IBOutlet private weak var btnA: UIButton!
    ///右边
    @IBOutlet private weak var btnB: UIButton!
    ///内容label
    @IBOutlet private weak var contentLabel: UILabel!
    ///占位图
    private lazy var palceHolderImage: UIImage = {
        let palceHolderImage = #imageLiteral(resourceName: "placeHolder")
        return palceHolderImage
    }()
    
    /// 按钮点击的回调
    var btnClickClosure: ((btnClickPosition)->Void)?
    
    ///数据模型
    var model = GHForTestModel() {
        didSet{
        topImageView.kf.setImage(with: URL.init(string: model.image ?? ""), placeholder: palceHolderImage)
        contentLabel.text = model.text
        }
    }
    
    @IBAction func ABtnClick(_ sender: UIButton) {
        if (btnClickClosure != nil) {
            btnClickClosure!(.left)
        }
    }
    
    @IBAction func BBtnClick(_ sender: UIButton) {
        if (btnClickClosure != nil) {
            btnClickClosure!(.right)
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
